<?php
require('config.php');
        $time=time();
		$sql="select  b.shopId,b.goodsId,b.groupPrice,b.groupMaxCount,b.startTime,b.endTime,a.goodsImg,a.goodsName from `".$oto."_goods` as a,`".$oto."_goods_group` as b where a.isGroup='1' and a.goodsId=b.goodsId and a.shopId=b.shopId and b.goodsGroupStatus='1' and startTime<='{$time}' and endTime>='{$time}' and a.goodsFlag='1' and a.goodsStatus='1' and b.groupStatus='1'";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$goods_info[]=$row;//将取得的所有数据赋值给person_info数组
		}
		if(isset($goods_info))
		{
			for($i=0;$i<count($goods_info);$i++)
			{
				$goodsId=$goods_info[$i]['goodsId'];
				$time_star=$goods_info[$i]['startTime'];
				$time_end=$goods_info[$i]['endTime'];
				$sql="select o.orderId,g.goodsNums from `".$oto."_orders` as o,`".$oto."_order_goods` as g where o.orderId=g.orderId and o.orderType='3' and g.goodsId='{$goodsId}' and o.orderStatus in ('0','1','2','3','4') ";
				$result=$db->query($sql);
				while($row=$result->fetch_assoc()){
					$order[$i][]=$row;//将取得的所有数据赋值给person_info数组
				}
				$sum=0;
				if(isset($order[$i]))
				{
					for($j=0;$j<count($order[$i]);$j++)
					{
						$sum+=$order[$i][$j]['goodsNums'];
					}
				}
				$goods_info[$i]['yimai']=$sum;
				$goods_info[$i]['time']=$time;
				$sql="select * from `".$oto."_goods_attributes`,`".$oto."_attributes` where ".$oto."_goods_attributes.goodsId='$goodsId' and isPriceAttr=1 and ".$oto."_goods_attributes.attrId=".$oto."_attributes.attrId order by ".$oto."_attributes.attrId ASC,".$oto."_goods_attributes.isRecomm DESC";
				$result=$db->query($sql);
				while($row=$result->fetch_assoc()){
					$isShuxing[]=$row;//将取得的所有数据赋值给person_info数组
				}
				if(isset($isShuxing)) $goods_info[$i]['isShuxing']=1;
				else $goods_info[$i]['isShuxing']=0;
			}
			echo json_encode($goods_info);
		}
		else echo '[]';
?>